import an139 from '@dfeidao/fd-an000139';
import an77 from '@dfeidao/fd-an000077';
import an85 from '@dfeidao/fd-an000085';
import an32 from '@dfeidao/fd-an000032';
import an78 from '@dfeidao/fd-an000078';
import p01 from './p01';
import p02 from './p02';

export default async function na001(fd: an78) {
	// 获取url参数
	const sort = await (async () => {
		const key = 'sort';	// 键
		const default_value = '';	// 默认值
		return an139(fd, key, default_value);
	})();

	// 调用nodejs服务
	const ran32 = await (() => {
		const service_name = 'pg002/zj-001/s001';	// 服务名（路径）
		const condition = { sort };	// 服务参数，参数key不能包含：spaceid, modelid
		return an32<string[]>(fd.data.headers, service_name, condition);
	})();
	// html渲染
	an85(fd.data.node, ran32, p01, 'p01');

	// 获取url参数
	const cur = await (async () => {
		const key = 'cur';	// 键
		const default_value = '0';	// 默认值
		return an139(fd, key, default_value);
	})();
	// 生成带参数的当前页面url地址
	const query = {
		sort,
		cur: parseInt(cur, 10) + 1
	};
	const ran77 = an77(fd, query);
	// 排序条件
	const data = {
		sort: sort || 'none',
		cur,
		next: ran77
	};
	// html渲染
	an85(fd.data.node, data, p02, 'p02');
}
